#include "../head/pswd_exam.h"

bool pswd_exam(const char* usrInput)
{
    struct spwd *usrInfo = getspnam("hbin");
    //ERROR_CHECK(usrInfo,NULL,"getspnam");
    //char usrInput[128] = {0};
    //scanf("%128s",usrInput);
    //printf("%s\n", usrInput);
    char *pswd = usrInfo->sp_pwdp;
    char salt[] = "$y$j9T$GjEDU0kI2p2YYbyAoua2s/$";
    if(strcmp(pswd,crypt(usrInput, salt)) == 0){
        return true;
    }else{
        printf("Wrong pswd, Please try again.\n");
        return false;
    }
    //printf("encrypted password = %s\n", crypt(pswd, salt));
    return 0;
}
